package cn.threewaters.qtyy.web.controller.business;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.baomidou.mybatisplus.plugins.Page;

import cn.threewaters.qtyy.common.bean.PageBean;
import cn.threewaters.qtyy.common.bean.ResponseJson;
import cn.threewaters.qtyy.dic.one.queryparam.QueryLsjl;
import cn.threewaters.qtyy.dic.one.queryresult.ResultLsjl;
import cn.threewaters.qtyy.service.business.LsjlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

@Api(tags = "历史记录")
@Controller
@RequestMapping(value = "/lsjl")
public class LsjlController {
	@Autowired
	private LsjlService lsjlService;
	@ApiIgnore
	@ApiOperation(value = "历史记录页面")
	@RequestMapping(value = "/main", method = RequestMethod.GET)
	public ModelAndView main(ModelMap modelMap) {
		return new ModelAndView("business/lsjl/lsjl", modelMap);
	}

	@ApiOperation(value = "历史记录列表")
	@RequestMapping(value = "/lsjlLB", method = RequestMethod.GET)
	@ResponseBody
	public ResponseJson getList(PageBean page,QueryLsjl queryLsjl) throws Exception {
		String jcsj = queryLsjl.getJcsj();
		if (jcsj != null && jcsj.indexOf(" - ") > 0) {
			queryLsjl.setChecktimebegin(jcsj.split(" - ")[0]);
			queryLsjl.setChecktimestop(jcsj.split(" - ")[1]);
		}
		Page<ResultLsjl> pageResult = new Page<ResultLsjl>();
		List<ResultLsjl> lsjlLBs = lsjlService.queryLsjlLB(queryLsjl);
		pageResult.setRecords(lsjlLBs);
		pageResult.setTotal(lsjlLBs.size());
		return ResponseJson.builder().success(true).obj(pageResult).build();
	}
	

}
